Added a way to obtain an indication of the current task state#19
Merged
taiki-e merged 4 commits intosmol-rs:masterfrom Mar 4, 2022
VictorKoenders:task_state
Merged
Added a way to obtain an indication of the current task state#19taiki-e merged 4 commits intosmol-rs:masterfrom VictorKoenders:task_state
taiki-e merged 4 commits intosmol-rs:masterfrom
VictorKoenders:task_state
Conversation
Contributor
Author
|
Some options to remove the
|
Collaborator
|
I'm fine with bumping MSRV to 1.40. |
Contributor
Author
|
Rebased onto master |
taiki-e
reviewed
Mar 3, 2022
src/task.rs
Outdated
Comment on lines
408
to
412
Collaborator
There was a problem hiding this comment.
Considering that TaskState is non_exhaustive, the user can really only rely on state==Completed (since state==Running may change its meaning in the future).
So I am starting to think that it might actually be preferable to have a method that returns a bool like is_completed.
Collaborator
There was a problem hiding this comment.
std JoinHandle has a similar unstable feature, which appears to be planned to be renamed is_finished.
rust-lang/rust#94549
Contributor
Author
|
Switched to |
Collaborator
|
LGTM. Could you revert MSRV bump? |
Collaborator
|
Published in 4.2.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I ran into the issue a couple of times where I spawned a task with async_std::task::spawn, and I was interested in getting an indication of the state of this task.
In my specific case I'm spawning up a task that takes data from a
TcpStreamand sends it to aSender. This task does not have a noticeable output, however I would like to periodically check if this task is still running and didn't panic or something.